<html>
<head>
<title>Search user</title>
<link rel='stylehseet' href='style.css' > 
<link type="text/css" href="css/smoothness/jquery-ui-1.8.11.custom.css" rel="Stylesheet" />	
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.11.custom.min.js"></script>
	<script>
	
	var proov = new Array(<?php require 'studentdata.php';?>);
	$(function() {
		$( "#birds" ).autocomplete({
			source: proov,//"testdata.php",
			minLength: 2,
			
			select: function( event, ui ) {
				//console.log(event);
				document.getElementById('hide').value=ui.item.value;
				//alert(ui.item.value);
			} 
		});
	});
	</script>

</head>
<body>
<div class="demo">

<div class="ui-widget">
	<input type="text" id="birds" />
</div>
  
<div>
    <form action="Users.php" method="post">
        <input id="hide" type="hidden" name="test" value="">
        <input type="submit"> 
    </form>
	<?php 
        if (isset($_POST['test'])){
            //echo $_POST['test'];
            require 'dbconnect.php';
            $nimi = &$_POST['test'];
           // $query = ;
            //echo $query; "SELECT * FROM Persons WHERE nimi='".$_POST['test']."'"."\""
            $result = mysql_query("SELECT * FROM students WHERE nimi='".$nimi."'");
            //$row = mysql_fetch_array($result);
            echo "<table border='1'>
            <tr>
                <th>Nimi</th>
                <th>Isikukood</th>
                <th>Aadress</th>
                <th>Telefon</th>
                <th>Email</th>
            </tr>";
        	
        	while($row = mysql_fetch_array($result)){
        	    echo "<tr>";
        	    echo "<td>". $row['nimi']. "</td>";
        	    echo "<td>". $row['isikukood']. "</td>";
        	    echo "<td>". $row['aadress']. "</td>";
        	    echo "<td>". $row['telefon']. "</td>";
        	    echo "<td>". $row['email']. "</td>";
        	}
        	
        	echo "</table>";
        }
    ?>
    
</div>

</div><!-- End demo -->

</body>
</html>



<?php



